//
//  TSBlackViewController.m
//  自定义转场动画
//
//  Created by 唐铁山 on 2018/9/11.
//  Copyright © 2018年 唐铁山. All rights reserved.
//

#import "TSBlackViewController.h"
#import "TSControllerTransition.h"

@interface TSBlackViewController ()<UINavigationControllerDelegate>

@end

@implementation TSBlackViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.delegate = self;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)redButtonClicked:(id)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    NSLog(@"touched");
}


#pragma mark - UINavigationControllerDelegate
- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC {

    if (operation == UINavigationControllerOperationPop) {
        TSControllerTransition *transition = [TSControllerTransition new];
        transition.push = NO;
        return transition;
    }

    return nil;
}

@end
